# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html

import csv, os
# 保存item数据
class TencentPipeline(object):
    def __init__(self):
        print('------------')
        self.filename = open('tencent.csv', 'w', encoding='utf-8', newline='')
        self.writer = csv.writer(self.filename)
        print(1111111111)

    def process_item(self, item, spider):
        print('正在写入....')
        if item['positionname']:
            self.writer.writerow([item['positionname'], item['positionType'], item['peopleNum'], item['workLocation'], item['publishTime']])

        return item

    def close_spider(self, spider):
        self.filename.close()
